<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--引用vue和axios-->
    <script src="js/plugins/vue/dist/vue.js"></script>
    <script src="js/plugins/axios/dist/axios.js"></script>
    <!--全局配置基础文件-->
    <script src="js/plugins/common.js"></script>
</head>
<body>
    hahaha
    <div id="app"></div>
</body>
    <script type="text/javascript">
        new Vue({
            el:"#app",
            data:{},
            methods:{

            },
            mounted(){
                var url = location.href;
                /*有个一工具类*/
                var jsonobj = parseUrlParams2Obj(url);
                //获取授权码
                var code = jsonobj.code;

                this.$http.get("/logininfo/weChat/"+code)
                .then(res=>{
                    if(res.data.success){
                        // 1. 把key（token）， user  存localStorage中
                        //获取token
                        var token = res.data.resultObj.token;
                        //用户信息
                        var logininfo = res.data.resultObj.logininfo;
                        var menus = res.data.resultObj.menus;
                        var permissions = res.data.resultObj.permissions;
                        localStorage.setItem("token",token);
                        //把json对象转成json字符串
                        localStorage.setItem("logininfo",JSON.stringify(logininfo));
                        localStorage.setItem("menus",JSON.stringify(menus));
                        localStorage.setItem("permissions",JSON.stringify(permissions));
                        // 2. 跳转后台首页
                        location.href="index.html";
                    }else{//没有绑定
                        var param = res.data.resultObj;
                        location.href="binder.html"+param;
                    }
                }).catch(res=>{
                    alert("系统异常");
                })

            }
        })
    </script>
</html>